﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="get_email_contact.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Letter.get_email_contact" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <% //species, filter, sended %>
    <% var species = Request.QueryString["ddl_speciesEmail"]; %>
    <% var sended = Request.QueryString["ddl_sendedEmail"]; %>
    <% var filter = Request.QueryString["ddl_filterEmail"]; %>

    <%//sended when don't have variable set
        if (sended == "0")
        { %>
    <% //select email species = contact and it not sended
        if (species == "1")
        {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Họ tên</th>
                <th>Email</th>
                <th>Ngày gửi</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%//ngay gui, ho ten, email
                var get_email_contact = new TblContactController().FetchAll().ToList();
            %>

            <%
                if (filter == "0")
                {
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "1")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderByDescending(x => x.DateX))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "2")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }

                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    //timkiemtheoten
                    get_email_contact = new TblContactController().FetchAll().ToList();
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())) || email_contact.Phone.ToLower().Contains(searchText.ToLower()))
                        {

                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%}
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "1")
        { %>
    <% if (species == "1")
        {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Họ tên</th>
                <th>Email</th>
                <th>Ngày gửi</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%//ngay gui, ho ten, email
                var get_email_contact = new TblContactController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended == null).ToList();
            %>

            <%
                if (filter == "0")
                {
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "1")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderByDescending(x => x.DateX))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "2")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }

                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblContactController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())) || email_contact.Phone.ToLower().Contains(searchText.ToLower()))
                        {

                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%}
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "2")
        { %>
    <% if (species == "1")
        {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Họ tên</th>
                <th>Email</th>
                <th>Ngày gửi</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%//ngay gui, ho ten, email
                var get_email_contact = new TblContactController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended != null).ToList();
            %>

            <%
                if (filter == "0")
                {
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "1")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderByDescending(x => x.DateX))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "2")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblContact email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }

                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblContactController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblContact email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())) || email_contact.Phone.ToLower().Contains(searchText.ToLower()))
                        {

                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_contact_id_<%= email_contact.Id%>" onclick="get_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <td><%= email_contact.DateX %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%}
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "0")
        {
            if (species == "2")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Tên</th>
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblFeedbackController().FetchAll().ToList();
            %>
            <% if (filter == "1" || filter == "0")
                {
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <% if (filter == "2")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "3")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.Email))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblFeedbackController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                            }
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "1")
        {
            if (species == "2")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Tên</th>
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblFeedbackController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended == null).ToList();
            %>
            <% if (filter == "1" || filter == "0")
                {
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <% if (filter == "2")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "3")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.Email))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblFeedbackController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                            }
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "2")
        {
            if (species == "2")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Tên</th>
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblFeedbackController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended != null).ToList();
            %>
            <% if (filter == "1" || filter == "0")
                {
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>

            <% if (filter == "2")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.FullName))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "3")
                {
                    foreach (TblFeedback email_contact in get_email_contact.OrderBy(x => x.Email))
                    {

                        if (email_contact.Viewed == true)
                        {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblFeedbackController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblFeedback email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.FullName).ToLower().Contains(convertToUnSign(searchText.ToLower())) || convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
                            if (email_contact.Viewed == true)
                            {%>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% }
                else
                {
            %>
            <tr id="email_feedback_contact_id_<%= email_contact.Id%>" onclick="get_feedback_mail_info_contact(<%= email_contact.Id %>)" class="notViewed">
                <td><%= email_contact.FullName %></td>
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                            }
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "0")
        {
            if (species == "3")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblCustomerEmailController().FetchAll();

            %>
            <%
                if (filter == "0" || filter == "1" || filter == "2")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblCustomerEmailController().FetchAll();
                    //timkiemtheoten
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "1")
        {
            if (species == "3")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblCustomerEmailController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended == null).ToList();
            %>
            <%
                if (filter == "0" || filter == "1" || filter == "2")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblCustomerEmailController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>

    <% if (sended == "2")
        {
            if (species == "3")
            {
    %>
    <table class="letter-list-table w3-table w3-white ">
        <thead>
            <tr class="w3-light-grey">
                <th>Email</th>
                <th>Tình trạng</th>
            </tr>
        </thead>
        <tbody>
            <%
                var get_email_contact = new TblCustomerEmailController().FetchAll().ToList();
                get_email_contact = get_email_contact.Where(x => x.Sended != null).ToList();
            %>
            <%
                if (filter == "0" || filter == "1" || filter == "2")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "3")
                {
                    foreach (TblCustomerEmail email_contact in get_email_contact.OrderBy(x => x.Email))
                    {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <% 
                    }
                }
            %>

            <%
                if (filter == "4")
                {
                    var searchText = Request.QueryString["searchText"];
                    get_email_contact = new TblCustomerEmailController().FetchAll().ToList();
                    //timkiemtheoten
                    foreach (TblCustomerEmail email_contact in get_email_contact)
                    {
                        if (convertToUnSign(email_contact.Email).ToLower().Contains(convertToUnSign(searchText.ToLower())))
                        {
            %>
            <tr id="email_customer_contact_id_<%= email_contact.Id%>" onclick="get_customer_mail_info_contact(<%= email_contact.Id %>)" class="Viewed">
                <td><%= email_contact.Email %></td>
                <%= sendedView(email_contact.Sended) %>
            </tr>
            <%
                        }
                    }
                }
            %>
        </tbody>
    </table>
    <%
            }
        }
    %>
</body>
</html>
